﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;

namespace LNUGame.Model
{
    /// <summary>
    /// Represents an enemy with a position and direction that is allowed to move along the x-axis
    /// </summary>
    class Enemy : MovingActor
    {
        private const int MOVE_RIGHT = 1;
        private const int MOVE_LEFT = -1;

        private const float SPEED_MOVING = 5.5f;

        /// <summary>
        /// Default constructor. Creates an instance of Enemy with a starting position of x = 0, y = 0
        /// </summary>
        public Enemy() : this(new Vector2(0.0f, 0.0f)){ }

        /// <summary>
        /// Constructor that creates an instance of Enemy with a supplied starting position and a default size that begins to move to the left as soon it is created
        /// </summary>
        /// <param name="a_position">The starting position of this instance</param>
        public Enemy(Vector2 a_position)
        {
            m_centerBottomPosition = a_position;
            m_size = new Vector2(0.6f, 1.0f);
            MoveLeft();
        }

        /// <summary>
        /// Updates the position of this instance
        /// </summary>
        /// <param name="a_elapsedTime"></param>
        internal void Update(float a_elapsedTime)
        {
            m_centerBottomPosition += new Vector2(base.Velocity.X * a_elapsedTime, 0.0f);
        }

        /// <summary>
        /// Moves this instance to the right
        /// Changes facing to the right
        /// </summary>
        internal void MoveRight()
        {
            m_velocity = new Vector2(SPEED_MOVING * MOVE_RIGHT, 0.0f);
            m_currentDirection = Direction.RIGHT;
        }

        /// <summary>
        /// Moves this instance to the left
        /// Changes facing to the left
        /// </summary>
        internal void MoveLeft()
        {
            m_velocity = new Vector2(SPEED_MOVING * MOVE_LEFT, 0.0f);
            m_currentDirection = Direction.LEFT;
        }
    }
}